//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2024 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto-codegenerator.
// DO NOT EDIT.

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
@_exported import SotoCore

/// Service object for interacting with AWS MarketplaceReporting service.
///
/// The Amazon Web Services Marketplace GetBuyerDashboard API enables you to get a procurement insights dashboard programmatically. The API gets the agreement and cost analysis dashboards with data for all of the Amazon Web Services accounts in your Amazon Web Services Organization.  To use the Amazon Web Services Marketplace Reporting API, you must complete the following prerequisites:   Enable all features for your organization. For more information, see Enabling all features for an organization with Organizations, in the Organizations User Guide.   Call the service as the Organizations management account or an account registered as a delegated administrator for the procurement insights service. For more information about management accounts, see Tutorial: Creating and configuring an organization and Managing the management account with Organizations, both in the Organizations User Guide. For more information about delegated administrators, see Using delegated administrators, in the Amazon Web Services Marketplace Buyer Guide.   Create an IAM policy that enables the aws-marketplace:GetBuyerDashboard and organizations:DescribeOrganization permissions. In addition, the management account requires the organizations:EnableAWSServiceAccess and iam:CreateServiceLinkedRole permissions to create. For more information about creating the policy, see Policies and permissions in Identity and Access Management, in the IAM User Guide.  Access can be shared only by registering the desired linked account as a delegated administrator. That requires organizations:RegisterDelegatedAdministrator organizations:ListDelegatedAdministrators and organizations:DeregisterDelegatedAdministrator permissions.    Use the Amazon Web Services Marketplace console to create the AWSServiceRoleForProcurementInsightsPolicy service-linked role. The role enables Amazon Web Services Marketplace procurement visibility integration. The management account requires an IAM policy with the organizations:EnableAWSServiceAccess and iam:CreateServiceLinkedRole permissions to create the service-linked role and enable the service access. For more information, see Granting access to Organizations and Service-linked role to share procurement data in the Amazon Web Services Marketplace Buyer Guide.   After creating the service-linked role, you must enable trusted access that grants Amazon Web Services Marketplace permission to access data from your Organizations. For more information, see Granting access to Organizations in the Amazon Web Services Marketplace Buyer Guide.
public struct MarketplaceReporting: AWSService {
    // MARK: Member variables

    /// Client used for communication with AWS
    public let client: AWSClient
    /// Service configuration
    public let config: AWSServiceConfig

    // MARK: Initialization

    /// Initialize the MarketplaceReporting client
    /// - parameters:
    ///     - client: AWSClient used to process requests
    ///     - region: Region of server you want to communicate with. This will override the partition parameter.
    ///     - partition: AWS partition where service resides, standard (.aws), china (.awscn), government (.awsusgov).
    ///     - endpoint: Custom endpoint URL to use instead of standard AWS servers
    ///     - middleware: Middleware chain used to edit requests before they are sent and responses before they are decoded 
    ///     - timeout: Timeout value for HTTP requests
    ///     - byteBufferAllocator: Allocator for ByteBuffers
    ///     - options: Service options
    public init(
        client: AWSClient,
        region: SotoCore.Region? = nil,
        partition: AWSPartition = .aws,
        endpoint: String? = nil,
        middleware: AWSMiddlewareProtocol? = nil,
        timeout: TimeAmount? = nil,
        byteBufferAllocator: ByteBufferAllocator = ByteBufferAllocator(),
        options: AWSServiceConfig.Options = []
    ) {
        self.client = client
        self.config = AWSServiceConfig(
            region: region,
            partition: region?.partition ?? partition,
            serviceName: "MarketplaceReporting",
            serviceIdentifier: "reporting-marketplace",
            signingName: "aws-marketplace",
            serviceProtocol: .restjson,
            apiVersion: "2018-05-10",
            endpoint: endpoint,
            errorType: MarketplaceReportingErrorType.self,
            middleware: middleware,
            timeout: timeout,
            byteBufferAllocator: byteBufferAllocator,
            options: options
        )
    }





    // MARK: API Calls

    /// Generates an embedding URL for an Amazon QuickSight dashboard for an anonymous user.  This API is available only to Amazon Web Services Organization management accounts or delegated administrators registered for the procurement insights (procurement-insights.marketplace.amazonaws.com) feature.  The following rules apply to a generated URL:   It contains a temporary bearer token, valid for 5 minutes after it is generated. Once redeemed within that period, it cannot be re-used again.   It has a session lifetime of one hour. The 5-minute validity period runs separately from the session lifetime.
    @Sendable
    @inlinable
    public func getBuyerDashboard(_ input: GetBuyerDashboardInput, logger: Logger = AWSClient.loggingDisabled) async throws -> GetBuyerDashboardOutput {
        try await self.client.execute(
            operation: "GetBuyerDashboard", 
            path: "/getBuyerDashboard", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Generates an embedding URL for an Amazon QuickSight dashboard for an anonymous user.  This API is available only to Amazon Web Services Organization management accounts or delegated administrators registered for the procurement insights (procurement-insights.marketplace.amazonaws.com) feature.  The following rules apply to a generated URL:   It contains a temporary bearer token, valid for 5 minutes after it is generated. Once redeemed within that period, it cannot be re-used again.   It has a session lifetime of one hour. The 5-minute validity period runs separately from the session lifetime.
    ///
    /// Parameters:
    ///   - dashboardIdentifier: The ARN of the requested dashboard.
    ///   - embeddingDomains: Fully qualified domains that you add to the allow list for access to the generated URL that is then embedded. You can list up to two domains or subdomains in each API call. To include all subdomains under a specific domain, use *. For example, https://*.amazon.com includes all subdomains under  https://aws.amazon.com.
    ///   - logger: Logger use during operation
    @inlinable
    public func getBuyerDashboard(
        dashboardIdentifier: String,
        embeddingDomains: [String],
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> GetBuyerDashboardOutput {
        let input = GetBuyerDashboardInput(
            dashboardIdentifier: dashboardIdentifier, 
            embeddingDomains: embeddingDomains
        )
        return try await self.getBuyerDashboard(input, logger: logger)
    }
}

extension MarketplaceReporting {
    /// Initializer required by `AWSService.with(middlewares:timeout:byteBufferAllocator:options)`. You are not able to use this initializer directly as there are not public
    /// initializers for `AWSServiceConfig.Patch`. Please use `AWSService.with(middlewares:timeout:byteBufferAllocator:options)` instead.
    public init(from: MarketplaceReporting, patch: AWSServiceConfig.Patch) {
        self.client = from.client
        self.config = from.config.with(patch: patch)
    }
}
